<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>

<title>{$lang.login_to} {$lang.rl_admin_panel}</title>

<meta name="generator" content="reefless_admin" />
<meta http-equiv="Content-Type" content="text/html; charset={$config.encoding}" />
<link href="{$rlTplBase}css/login.css" type="text/css" rel="stylesheet" />
<link href="{$rlTplBase}css/style.css" type="text/css" rel="stylesheet" />
<link rel="shortcut icon" href="{$rlTplBase}img/favicon.ico" />
<link href="{$rlTplBase}css/ext/ext-all.css" type="text/css" rel="stylesheet" />
<link href="{$rlTplBase}css/ext/rlExt.css" type="text/css" rel="stylesheet" />

{$ajaxJavascripts}

<script type="text/javascript" src="{$smarty.const.RL_LIBS_URL}jquery/jquery.js"></script>
<script type="text/javascript" src="{$smarty.const.RL_LIBS_URL}extJs/ext-base.js"></script>
<script type="text/javascript" src="{$smarty.const.RL_LIBS_URL}extJs/ext-all.js"></script>
<!--script type="text/javascript" src="{$rlBase}js/lib.js"></script-->
<script type="text/javascript" src="{$rlBase}js/login.js"></script>
<script type="text/javascript" src="{$rlBase}js/md5.js"></script>

</head>
<body>
<div id="height">
	<div id="middle">
		<div id="login_block">
			<div class="top">
				<div class="left"></div>
				<div class="center"></div>
				<div class="right"></div>
			</div>
			<div class="clear"></div>
			
			<div class="middle_outer">
				<div class="middle_inner">
					<div id="logo"></div>
					
					<form name="login" action="" method="post" onsubmit="return false;">
						<div class="relative" style="margin: 0 0 5px">
							<input style="width: 215px;" maxlength="25" type="text" id="username" name="username" />
							<div id="username_hint" class="input_hint">{$lang.username}</div>
						</div>
						
						<div class="relative" style="margin: 0 0 5px">
							<input style="width: 215px;" maxlength="25" type="password" id="password" name="password" />
							<div id="password_hint" class="input_hint">{$lang.password}</div>
						</div>
						
						<select {if $langCount < 2}class="disabled"{/if} title="{$lang.rl_interface}" id="interface" style="width: 100px;" {if $langCount < 2}disabled="disabled"{/if}>
							{foreach from=$languages item='languages' name='lang_foreach'}
								<option value="{$languages.Code}" {if $smarty.const.RL_LANG_CODE == $languages.Code} selected="selected"{/if}>{$languages.name}</option>
							{/foreach}
						</select>
						
						<div style="margin-top: 20px;">
							<input id="login_button" type="submit" name="go" value="{$lang.login}" />
						</div>
					</form>
				</div>
			</div>
			
			<div class="bottom">
				<div class="left"></div>
				<div class="center"></div>
				<div class="right"></div>
			</div>
		</div>
	</div>
	<div id="crosspiece"></div>
</div>

<!-- copyrights -->
<div id="login_footer">
	&copy; <a href="{$lang.flynax_url}">{$lang.copy_rights}</a> {$lang.version} <b>{$config.rl_version}</b>
</div>
<!-- copyrights end -->

<script type="text/javascript">//<![CDATA[
var sec_key = "{$config.security_key}";
var lang = new Array();

{foreach from=$ext_phrases item='phrase' key='key'}
	lang["{$key}"] = "{$phrase|replace:'/':'&002F;'|regex_replace:'/[\r\t\n]/':'<br />'}";
{/foreach}

{if isset($smarty.get.session_expired) || $smarty.get.action == 'session_expired'}
	fail_alert('', '{$lang.session_expired}');
{/if}

{literal}

var is_visible = true;

$(document).ready(function(){
	eventListener();
	
	/* submit handler */
	$('#login_button').click(function(){
		jsLogin("{/literal}{$lang.rl_empty_username|regex_replace:'/[\r\t\n]/':'<br />'}{literal}", "{/literal}{$lang.rl_empty_pass|regex_replace:'/[\r\t\n]/':'<br />'}{literal}");
	});
	
	/* input fields handler */
	$('#username').focus(function(){
		$('#username_hint').fadeOut();
	}).click(function(){
		$('#username_hint').fadeOut();
	}).keydown(function(){
		$('#username_hint').fadeOut('fast');
	}).blur(function(){
		if ( $(this).val() == '' && !$('#username_hint').is(':visible') )
		{
			$('#username_hint').fadeIn();
		}
	});
	
	$('#password').focus(function(){
		$('#password_hint').fadeOut();
	}).blur(function(){
		if ( $(this).val() == '' )
		{
			$('#password_hint').fadeIn();
			eventListener();
		}
	});
	
	$('#username_hint').click(function(){
		$('input#username').focus();
	});
	$('#password_hint').click(function(){
		$('input#password').focus();
	});
	
	/* chrome yellow autocomplete fix */
	var user_agent = navigator.userAgent.toLowerCase();
	
	if ( user_agent.indexOf("chrome") >= 0 )
	{
		$(window).load(function(){
			$('input:-webkit-autofill').each(function(){
				var text = $(this).val();
				var name = $(this).attr('name');
				$(this).after(this.outerHTML).remove();
				$('input[name='+ name +']').val(text);
				$('#username_hint').hide();
				$('#password_hint').hide();
		    });
		});
	}
	else
	{
		$(window).load(function(){
			if ( $('input#username').val() != '' )
			{
				$('#username_hint').hide();
			}
			if ( $('input#password').val() != '' )
			{
				$('#password_hint').hide();
			}
		});
	}
	
	/* height handler */
	var heightHandler = function(){
		var height = Math.floor((( $(window).height() - 54 ) / 2 ) - 155);
		height = height <= 0 ? 30 : height;
		
		$('#middle').css('padding-top', height);
	};
	
	heightHandler();
	
	$(window).resize(function(){
		heightHandler();
	});
});

var do_listen = false;
var listener_time = 0;
function eventListener()
{
	if ( $('#password').val() != '' )
	{
		$('#password_hint').fadeOut('fast');
		return;
	}
	listener_time = setTimeout('eventListener()', 400);
}

{/literal}
//]]>
</script>

{rlHook name='apTplLogin'}

</body>
</html>